export const pageLoading = {
  methods: {
    eventPostAddLoading({ popId, pageId }){
      let pageOrPopComNum = 0
      _.forEach(this.currentPage.events, (event) => {
        if(event.isInitComp && !event.isPost){
          pageOrPopComNum += 1
        }
      })
      _.forEach(this.currentPage.components, (componentData) => {
        _.forEach(componentData.events, event => {
          if (event.isInitComp && !event.isPost) {
            pageOrPopComNum += 1
          }
        });
      });
      let isLoading
      if (pageOrPopComNum > 0) {
        isLoading = true
        this.$store.commit("updatePageOrPopComNum", { pageOrPopComNum })
      } else {
        isLoading = false
        if(popId){
          this.showPopById({ popId })
        }else if(pageId){
          this.showPageById({ pageId })
        }
      }
      this.$store.commit("updateLoading", { isLoading })
    }
  }
}